package net.wangds.dymodel.ctrl;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.wangds.dymodel.meta.entity.DyModelDefEntity;
import net.wangds.dymodel.service.DyModelDefOpService;
import net.wangds.jpa.ctrl.AbstractJpaServiceCtrl;
import net.wangds.web.entrypoint.BaseMultipleResp;
import net.wangds.web.entrypoint.PagingForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;

@Api(tags="动态模型管理")
@RestController
@RequestMapping("/dymdl")
@SuppressWarnings("unused")
public class DyModelCtrl extends AbstractJpaServiceCtrl<DyModelDefEntity> {

    /**
     * 专家库JPA服务实例.
     */
    @Autowired
    private DyModelDefOpService mmServ;

    @Override
    protected DyModelDefOpService fetchService() {
        return mmServ;
    }

    @ApiOperation("根据英文名称查询")
    @RequestMapping(value = "/ByName/{name}", method = RequestMethod.POST)
    public BaseMultipleResp<DyModelDefEntity> byName(
            @PathVariable("name")
                    String name,
            @RequestBody
                    PagingForm page) {
        PageRequest paging = mmConvPf2Pr.convert(page);
        return mmConvPage2Resp.convert(mmServ.findByName(name, paging));
    }

}

